export const downloadCvs2Img = (cvs) => {
	let $a = document.createElement('a');
	$a.download = 'Download.jpg';
	$a.target = '_blank';
	const url = cvs.toDataURL('image/jpg');
	$a.href = url;
	if (typeof MouseEvent === 'function') {
		let evt = new MouseEvent('click', {
			view: window,
			bubbles: true,
			cancelable: false,
		});
		$a.dispatchEvent(evt);
	} else if (window.navigator.msSaveOrOpenBlob) {
			let bstr = atob(url.split(',')[1]);
			let n = bstr.length;
			let u8arr = new Uint8Array(n);
			while (n--) {
				u8arr[n] = bstr.charCodeAt(n);
			}
			let blob = new Blob([u8arr]);
			window.navigator.msSaveOrOpenBlob(blob, 'Download.jpg');
		} else {
			let lang = model.get('lang');
			let html = `${'' +
				'<body style="margin:0;">' +
				'<img src="'}${url}" style="max-width:100%;" title="${(lang && lang[0]) || ''}" />` +
				'</body>';
			let tab = window.open();
			tab.document.write(html);
		}
};
